﻿/*******************************************************************************
 * Copyright © 2017 FriendStar.Framework 版权所有
 * Author: HYF
 * Description: FriendStar快速开发平台
 * Website：http://www.FriendStar.cn
*********************************************************************************/
using FriendStar.Code;
using SqlSugarRepository;
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Linq;
using System.Linq.Expressions;

namespace FriendStar.Data
{
    public interface IRepositoryBase : IDisposable
    {
        IRepositoryBase BeginTrans();
        DbParameter[] GetParameters(object obj);
        int GetParameterIndex(DbParameter[] parameters, string parameterName);
        void Commit();
        void RollBack();
        bool Insert<TEntity>(TEntity entity) where TEntity : class;
        bool Insert<TEntity>(List<TEntity> entitys) where TEntity : class;
        bool Update<TEntity>(TEntity entity) where TEntity : class;
        bool Update<T>(object rowObj, Expression<Func<T, bool>> expression) where T : class;
        bool UpdateColumns<T>(T rowObj, Expression<Func<T, bool>> expression, Expression<Func<T, object>> updateColumns) where T : class;
        bool Delete<TEntity>(TEntity entity) where TEntity : class;
        bool Delete<TEntity>(Expression<Func<TEntity, bool>> predicate) where TEntity : class;
        TEntity FindEntity<TEntity>(object keyValue) where TEntity : class, new();
        TEntity FindEntity<TEntity>(Expression<Func<TEntity, bool>> predicate) where TEntity : class, new();
        ISugarQueryable<TEntity> IQueryable<TEntity>() where TEntity : class, new();
        ISugarQueryable<TEntity> IQueryable<TEntity>(string tableName) where TEntity : class, new();
        ISugarQueryable<TEntity> IQueryable<TEntity>(Expression<Func<TEntity, bool>> predicate) where TEntity : class, new();
        List<TEntity> FindList<TEntity>(string strSql) where TEntity : class;
        List<TEntity> FindList<TEntity>(string strSql, object dbParameter) where TEntity : class;
        List<TEntity> FindList<TEntity>(Pagination pagination) where TEntity : class, new();
        List<TEntity> FindList<TEntity>(Expression<Func<TEntity, bool>> predicate, Pagination pagination) where TEntity : class, new();

        #region 存储过程执行
        List<TEntity> ExecuteStoredProcedure<TEntity>(string storedProcedureName, object obj);
        #endregion
    }
}
